package com.sandbox.ws;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.UnexpectedInputException;

import com.edb.finance.collateral.ws.checkin.v1.CheckInRequest;
import com.edb.finance.collateral.wsdomain.collateralitem.v1.Collateralitem;
import com.evry.finance.collateral.wsdomain.Database;

public class QueueReader implements ItemReader<CheckInRequest> {

	private BlockingQueue<CheckInRequest> queue;
	
	public CheckInRequest read() throws Exception, UnexpectedInputException {
		CheckInRequest item = queue.poll(20, TimeUnit.SECONDS);
//		if(item == null){
			System.out.println("queue.size(): " + queue.size());
//		}else{
//			System.out.println(queue.size());
//		}
		return item;
	}
	
	public void setQueue(BlockingQueue<CheckInRequest> queue) {
		this.queue = queue;
	}
}